return {
    'MeanderingProgrammer/render-markdown.nvim',
    ft = { 'markdown', 'quarto' },
    dependencies = {
        'nvim-treesitter/nvim-treesitter',
        'echasnovski/mini.nvim',
    },
    config = function()
        local enabled_heading_number         = true
        local disable_heading_background     = false
        local disable_codeblock_background   = true
        local disable_inlinecode_background  = true

        local function boldify(str)
            local heavy = {
                ['0'] = '𝟎', ['1'] = '𝟏', ['2'] = '𝟐', ['3'] = '𝟑',
                ['4'] = '𝟒', ['5'] = '𝟓', ['6'] = '𝟔', ['7'] = '𝟕',
                ['8'] = '𝟖', ['9'] = '𝟗',
            }
            return (str:gsub('.', function(c) return heavy[c] or c end))
        end

        local function arabic_to_zh(n)
            local zh = { '零', '一', '二', '三', '四', '五', '六', '七', '八', '九' }
            local units = { '', '十', '百', '千', '万' }
            local digs, s = {}, ''
            while n > 0 do
                table.insert(digs, 1, n % 10)
                n = math.floor(n / 10)
            end
            for i, d in ipairs(digs) do
                local u = units[#digs - i + 1]
                if d ~= 0 then
                    s = s .. zh[d + 1] .. u
                elseif not s:match('零$') then
                    s = s .. '零'
                end
            end
            return s:gsub('零+', '零'):gsub('零$', ''):gsub('一十', '十')
        end

        local function make_heading_renderer(enabled)
            if not enabled then
                return function(_) return '' end
            end
            return function(ctx)
                local parts = { arabic_to_zh(ctx.sections[1]) .. '、' }
                if #ctx.sections > 1 then
                    local tail = {}
                    for i = 2, #ctx.sections do
                        table.insert(tail, boldify(tostring(ctx.sections[i])))
                    end
                    table.insert(parts, table.concat(tail, '.'))
                end
                local result = table.concat(parts)
                return ctx.level == 1 and result or (result .. ' ')
            end
        end

        local function update_render_markdown()
            require('render-markdown').setup({
                preset = 'none',
                heading = {
                    sign         = false,
                    position     = 'inline',
                    icons        = make_heading_renderer(enabled_heading_number),
                    render_modes = { 'n', 'c', 't', 'i' },
                },
                paragraph = { 
                    -- left_margin = 4,
                },
                code = {
                    sign = false,
                    border = {
                        hl_group = 'RenderMarkdownCodeBorder',
                    },
                    inline = true,
                    inline_left = ' ',
                    inline_right = ' ',
                }
            })
        end

        update_render_markdown()

        vim.api.nvim_create_user_command('ToggleMarkdownHeadingNumber', function()
            enabled_heading_number = not enabled_heading_number
            update_render_markdown()
        end, { desc = '切换标题编号开关' })

        vim.keymap.set('n', '<leader>hn', ':ToggleMarkdownHeadingNumber<CR>', { desc = '切换标题编号', silent = true })

        local bg = vim.api.nvim_get_hl(0, { name = 'Normal' }).bg
        if bg and type(bg) == 'number' then
            local hex = string.format('#%06x', bg)

            if disable_heading_background then
                for i = 1, 6 do
                    vim.api.nvim_set_hl(0, 'RenderMarkdownH' .. i .. 'Bg', { bg = hex })
                end
            end

            if disable_inlinecode_background then
                vim.api.nvim_set_hl(0, 'RenderMarkdownCodeInline', { bg = hex })
            end

            if disable_codeblock_background then
                vim.api.nvim_set_hl(0, 'RenderMarkdownCode',       { bg = hex })
                vim.api.nvim_set_hl(0, 'RenderMarkdownCodeBg',     { bg = hex })
                vim.api.nvim_set_hl(0, 'RenderMarkdownCodeInfo',   { bg = hex })
                vim.api.nvim_set_hl(0, 'RenderMarkdownCodeBorder', { bg = hex })
            end
        end
    end,
}

